package b1.scenes.home.wanted
{
	import b1.net.*;
	import b1.players.*;
	import b1.scenes.home.picpane.*;
	import b1.utils.*;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.text.*;
	
	public class WantedDialog extends Sprite
	{
		
		public function WantedDialog(players:Array)
		{
			
			//加载背景图片
			super();
			var RankBackGround:Class = ResourceHelper.getInstance().getClassByName("RankBackGround");
			var wantedDialogBgr:Sprite = new RankBackGround();
			wantedDialogBgr.width = 500;
			wantedDialogBgr.height = 500;
			wantedDialogBgr.x = (BFont.stageWidth - wantedDialogBgr.width) / 2;
			wantedDialogBgr.y = (BFont.stageHeight - wantedDialogBgr.height) / 2;
			addChild(wantedDialogBgr);
			//标题
//			var titleText:TextField = new TextField();
//			titleText.selectable = false;
//        	titleText.autoSize = TextFieldAutoSize.LEFT;
//			titleText.defaultTextFormat = new TextFormat("微软雅黑", 20, 0xFF0032, true);
//			titleText.text = "装备勋章排行";
//			titleText.x = 80;
//			titleText.y = 30;
//			wantedDialogBgr.addChild(titleText);
			//“每日更新”
//			var titleText1:TextField = new TextField();
//			titleText1.selectable = false;
//        	titleText1.autoSize = TextFieldAutoSize.LEFT;
//			titleText1.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x000000);
//			titleText1.text = "每日更新时间\n23:00 - 24:00";
//			titleText1.x = 85;
//			titleText1.y = titleText.y + titleText.height + 30;
//			wantedDialogBgr.addChild(titleText1);
			
			var me:PlayerInfo = PlayerInfoHelper.getInstance().players[PlayerInfoHelper.getInstance().userId];
			var playerPicIcon:PlayerPicIcon;

			var Crown:Class = ResourceHelper.getInstance().getClassByName("Crown");
			var crown:Sprite = new Crown();
			crown.x = 350;
			crown.y = 80;
			
			playerPicIcon = new PlayerPicIcon(players[0]);
			playerPicIcon.x = 350;
			playerPicIcon.y = 140;
			addChild(playerPicIcon);
			addChild(crown);
			
			//如果我自己并未上榜
			if (me.equipRank > 9)
			{
				playerPicIcon = new PlayerPicIcon(me);
				playerPicIcon.x = 500;
				playerPicIcon.y = 140;
				addChild(playerPicIcon);
				//显示距离
				var DistArrow:Class = ResourceHelper.getInstance().getClassByName("DistArrow");
				var distArrow:Sprite = new DistArrow();
//				distArrow.width = 50;
//				distArrow.height = 10;
				distArrow.x = playerPicIcon.x - 70;
				distArrow.y = playerPicIcon.y + 50;
				addChild(distArrow);
				//距离文字
				var distText:TextField = new TextField();
	        	distText.autoSize = TextFieldAutoSize.LEFT;
				distText.selectable = false;
				distText.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x000000);
				distText.text = "距离";
				distText.x = distArrow.x + 15;
				distText.y = distArrow.y - 45;
				addChild(distText);
				var distNumText:TextField = new TextField();
	        	distNumText.autoSize = TextFieldAutoSize.LEFT;
				distNumText.selectable = false;
				distNumText.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x000000);
				distNumText.text = me.equipRank.toString();
				distNumText.x = distText.x + (distText.width - distNumText.width) / 2;
				distNumText.y = distText.y + 20;
				addChild(distNumText);
			}
			
			for (var i:int = 1; i < players.length; i++)
			{
				playerPicIcon = new PlayerPicIcon(players[i]);
				playerPicIcon.x = 270 + (i - 1) % 3  * 100;
				playerPicIcon.y = 235 + Math.floor((i - 1) / 3) * 95;
				addChild(playerPicIcon);
			}		
			
		}
		
	}
}